/* ============================================================

Copyright (c) 2007 Advanced Micro Devices, Inc.  All rights reserved.

Redistribution and use of this material is permitted under the following
conditions:

Redistributions must retain the above copyright notice and all terms of this
license.

In no event shall anyone redistributing or accessing or using this material
commence or participate in any arbitration or legal action relating to this
material against Advanced Micro Devices, Inc. or any copyright holders or
contributors. The foregoing shall survive any expiration or termination of
this license or any agreement or access or use related to this material.

ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE REVOCATION
OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL.

THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION AND WITHOUT ANY
REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR IN ANY WAY RELATED TO
SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED OPERATION, OR THAT IT IS FREE
FROM DEFECTS OR VIRUSES.  ALL OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER
EXPRESS, IMPLIED, OR STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
ACCURACY, COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT.
IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, REVENUE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED OR BASED ON ANY THEORY OF LIABILITY
ARISING IN ANY WAY RELATED TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE. THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES,
INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS
(US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL ACCEPTS
THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO DEVICES, INC. AND
ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND ALL LIABILITIES,
OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN DOLLARS (US $10.00). THE
FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE AND, IF ANY OF THESE TERMS ARE
CONSTRUED AS UNENFORCEABLE, FAIL IN ESSENTIAL PURPOSE, OR BECOME VOID OR
DETRIMENTAL TO ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
CONTRIBUTORS FOR ANY REASON, THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE
THIS MATERIAL SHALL TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL
SURVIVE ANY EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR
ACCESS OR USE RELATED TO THIS MATERIAL.

NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING THIS
MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE SUBJECT TO
RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED STATES OR OTHER
COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S. EXPORT CONTROL LAWS SUCH
AS THE EXPORT ADMINISTRATION REGULATIONS AND NATIONAL SECURITY CONTROLS AS
DEFINED THEREUNDER, AS WELL AS STATE DEPARTMENT CONTROLS UNDER THE U.S.
MUNITIONS LIST. THIS MATERIAL MAY NOT BE USED, RELEASED, TRANSFERRED, IMPORTED,
EXPORTED AND/OR RE-EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS,
INCLUDING U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS,
COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY CONTROLS.
MOREOVER, THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY
LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL.

NOTICE REGARDING THE U.S. GOVERNMENT AND DOD AGENCIES: This material is
provided with "RESTRICTED RIGHTS" and/or "LIMITED RIGHTS" as applicable to
computer software and technical data, respectively. Use, duplication,
distribution or disclosure by the U.S. Government and/or DOD agencies is
subject to the full extent of restrictions in all applicable regulations,
including those found at FAR52.227 and DFARS252.227 et seq. and any successor
regulations thereof. Use of this material by the U.S. Government and/or DOD
agencies is acknowledgment of the proprietary rights of any copyright holders
and contributors, including those of Advanced Micro Devices, Inc., as well as
the provisions of FAR52.227-14 through 23 regarding privately developed and/or
commercial computer software.

This license forms the entire agreement regarding the subject matter hereof and
supersedes all proposals and prior discussions and writings between the parties
with respect thereto. This license does not affect any ownership, rights, title,
or interest in, or relating to, this material. No terms of this license can be
modified or waived, and no breach of this license can be excused, unless done
so in a writing signed by all affected parties. Each term of this license is
separately enforceable. If any term of this license is determined to be or
becomes unenforceable or illegal, such term shall be reformed to the minimum
extent necessary in order for this license to remain in effect in accordance
with its terms as modified by such reformation. This license shall be governed
by and construed in accordance with the laws of the State of Texas without
regard to rules on conflicts of law of any state or jurisdiction or the United
Nations Convention on the International Sale of Goods. All disputes arising out
of this license shall be subject to the jurisdiction of the federal and state
courts in Austin, Texas, and all defenses are hereby waived concerning personal
jurisdiction and venue of these courts.

============================================================ */
#ifndef _FFT_KERNEL_H_
#define _FFT_KERNEL_H_

#include <cstring>
#include <cstdio>
#include <cstdlib>

#define CONST_SIZE 2048
#define SIN_SHEET_SIZE 12

#define SWITCHING_SHEET_SIZE 1984
#define SWITCHING_SHEET_SIZE_256 992

#define FFT_FILTER_SHEET_SIZE 2048
#define FFT_FILTER_SHEET_SIZE_256 1024
/* 256 filter array */
float FFT_filter_256 [] = {0.989380f,0.000000f,2.130493f,-0.000008f,4.767273f,-0.000062f,7.499451f,-0.000052f,9.806030f,-0.000038f,12.090698f,-0.000043f,14.628357f,-0.000069f,17.175903f,-0.000077f,19.542908f,-0.000006f,21.904541f,-0.000005f,24.406372f,-0.000059f,26.911682f,-0.000047f,29.302185f,-0.000040f,31.690369f,-0.000070f,34.175659f,-0.000072f,36.662659f,-0.000080f,39.065552f,-0.000020f,41.467163f,-0.000032f,43.942932f,-0.000086f,46.419800f,-0.000058f,48.830139f,-0.000059f,51.239685f,-0.000036f,53.709290f,-0.000065f,56.179810f,-0.000093f,58.595154f,0.000019f,61.009949f,0.000003f,63.475464f,-0.000045f,65.941406f,-0.000046f,68.360413f,-0.000042f,70.778992f,-0.000055f,73.241272f,-0.000079f,75.703979f,-0.000074f,78.125793f,-0.000034f,80.547180f,-0.000057f,83.007141f,-0.000125f,85.467285f,-0.000101f,87.891235f,-0.000094f,90.314880f,-0.000122f,92.772888f,-0.000152f,95.231140f,-0.000154f,97.656738f,-0.000082f,100.082214f,-0.000057f,102.538574f,-0.000136f,104.995300f,-0.000120f,107.422302f,-0.000091f,109.849121f,-0.000116f,112.304321f,-0.000147f,114.759674f,-0.000129f,117.187866f,-0.000074f,119.615936f,-0.000084f,122.070068f,-0.000138f,124.524292f,-0.000121f,126.953430f,-0.000122f,129.382446f,-0.000107f,131.835632f,-0.000145f,134.289001f,-0.000145f,136.718964f,-0.000077f,139.148895f,-0.000124f,141.601318f,-0.000137f,144.053833f,-0.000151f,146.484497f,-0.000116f,148.915131f,-0.000101f,151.366882f,-0.000129f,153.818695f,-0.000148f,156.250061f,-0.000070f,158.681335f,-0.000072f,161.132538f,-0.000139f,163.583801f,-0.000124f,166.015656f,-0.000080f,168.447510f,-0.000113f,170.898163f,-0.000122f,173.348907f,-0.000134f,175.781281f,-0.000069f,178.213654f,-0.000066f,180.663849f,-0.000113f,183.114105f,-0.000124f,185.546906f,-0.000115f,187.979614f,-0.000134f,190.429413f,-0.000176f,192.879242f,-0.000159f,195.312531f,-0.000092f,197.745728f,-0.000151f,200.195099f,-0.000203f,202.644592f,-0.000165f,205.078186f,-0.000187f,207.511688f,-0.000167f,209.960693f,-0.000215f,212.409851f,-0.000248f,214.843750f,-0.000137f,217.277649f,-0.000170f,219.726349f,-0.000225f,222.175171f,-0.000189f,224.609314f,-0.000156f,227.043457f,-0.000174f,229.491913f,-0.000202f,231.940430f,-0.000184f,234.374908f,-0.000166f,236.809357f,-0.000185f,239.257568f,-0.000245f,241.705841f,-0.000253f,244.140533f,-0.000210f,246.575226f,-0.000248f,249.023193f,-0.000239f,251.471252f,-0.000249f,253.906158f,-0.000201f,256.341156f,-0.000224f,258.788849f,-0.000261f,261.236694f,-0.000260f,263.671783f,-0.000239f,266.106903f,-0.000254f,268.554504f,-0.000256f,271.002075f,-0.000284f,273.437439f,-0.000212f,275.872772f,-0.000230f,278.320099f,-0.000302f,280.767578f,-0.000263f,283.203033f,-0.000246f,285.638550f,-0.000247f,288.085724f,-0.000254f,290.533020f,-0.000277f,292.968689f,-0.000223f,295.404327f,-0.000246f,297.851379f,-0.000275f,300.298523f,-0.000303f,302.734283f,-0.000227f,305.170074f,-0.000227f,307.617004f,-0.000301f,310.063934f,-0.000234f,312.499908f,-0.000146f,314.935883f,-0.000149f,317.382629f,-0.000208f,319.829468f,-0.000212f,322.265533f,-0.000127f,324.701599f,-0.000185f,327.148224f,-0.000200f,329.594940f,-0.000229f,332.031158f,-0.000156f,334.467377f,-0.000192f,336.913910f,-0.000207f,339.360504f,-0.000217f,341.796783f,-0.000159f,344.233063f,-0.000196f,346.679504f,-0.000212f,349.125977f,-0.000206f,351.562439f,-0.000164f,353.998840f,-0.000195f,356.445129f,-0.000207f,358.891541f,-0.000220f,361.328033f,-0.000217f,363.764557f,-0.000162f,366.210785f,-0.000186f,368.657043f,-0.000255f,371.093689f,-0.000137f,373.530304f,-0.000145f,375.976410f,-0.000194f,378.422607f,-0.000211f,380.859253f,-0.000151f,383.295929f,-0.000187f,385.742004f,-0.000181f,388.188080f,-0.000174f,390.624878f,-0.000168f,393.061584f,-0.000148f,395.507568f,-0.000203f,397.953644f,-0.000202f,400.390442f,-0.000165f,402.827271f,-0.000217f,405.273254f,-0.000215f,407.719177f,-0.000211f,410.156128f,-0.000158f,412.593079f,-0.000202f,415.038849f,-0.000209f,417.484802f,-0.000214f,419.921753f,-0.000149f,422.358704f,-0.000161f,424.804504f,-0.000219f,427.250305f,-0.000175f,429.687378f,-0.000153f,432.124420f,-0.000184f,434.570129f,-0.000249f,437.015900f,-0.000224f,439.453003f,-0.000188f,441.890076f,-0.000207f,444.335754f,-0.000197f,446.781433f,-0.000193f,449.218628f,-0.000158f,451.655762f,-0.000179f,454.101349f,-0.000180f,456.547058f,-0.000211f,458.984192f,-0.000126f,461.421387f,-0.000104f,463.866943f,-0.000144f,466.312592f,-0.000099f,468.749847f,-0.000084f,471.187073f,-0.000080f,473.632629f,-0.000168f,476.078186f,-0.000141f,478.515472f,-0.000086f,480.952728f,-0.000126f,483.398254f,-0.000148f,485.843781f,-0.000137f,488.281128f,-0.000085f,490.718445f,-0.000109f,493.163879f,-0.000127f,495.609406f,-0.000160f,498.046692f,-0.000101f,500.484039f,-0.000126f,502.929443f,-0.000151f,505.374939f,-0.000129f,507.812378f,-0.000102f,510.249695f,-0.000116f,512.695129f,-0.000133f,515.140564f,-0.000128f,517.577942f,-0.000147f,520.015381f,-0.000128f,522.460693f,-0.000121f,524.906128f,-0.000146f,527.343628f,-0.000081f,529.781006f,-0.000097f,532.226379f,-0.000150f,534.671753f,-0.000174f,537.109192f,-0.000060f,539.546631f,-0.000088f,541.991943f,-0.000083f,544.437317f,-0.000080f,546.874817f,-0.000023f,549.312256f,-0.000065f,551.757507f,-0.000115f,554.202881f,-0.000113f,556.640381f,-0.000064f,559.077881f,-0.000065f,561.523193f,-0.000082f,563.968506f,-0.000116f,566.406067f,-0.000073f,568.843567f,-0.000149f,571.288818f,-0.000112f,573.734131f,-0.000105f,576.171631f,-0.000054f,578.609131f,-0.000050f,581.054382f,-0.000082f,583.499695f,-0.000049f,585.937317f,-0.000092f,588.374817f,-0.000106f,590.820068f,-0.000115f,593.265381f,-0.000100f,595.702881f,-0.000057f,598.140442f,-0.000082f,600.585693f,-0.000039f,603.030945f,-0.000070f,605.468567f,-0.000082f,607.906067f,-0.000095f,610.351318f,-0.000045f,612.796631f,-0.000150f,615.234131f,-0.000023f,617.671692f,-0.000031f,620.116882f,-0.000107f,622.562195f,0.000034f,625.000000f,0.000000f,627.437561f,0.000035f,629.882751f,-0.000076f,632.328064f,-0.000060f,634.765625f,0.000010f,637.203125f,-0.000055f,639.648376f,-0.000041f,642.093628f,-0.000090f,644.531250f,-0.000012f,646.968811f,-0.000063f,649.414001f,-0.000064f,651.859314f,-0.000074f,654.296875f,-0.000019f,656.734375f,-0.000030f,659.179626f,-0.000048f,661.624939f,-0.000064f,664.062500f,-0.000044f,666.500000f,-0.000068f,668.945251f,-0.000045f,671.390564f,-0.000098f,673.828064f,-0.000070f,676.265625f,-0.000056f,678.710876f,-0.000038f,681.156189f,-0.000101f,683.593750f,-0.000012f,686.031250f,-0.000035f,688.476563f,-0.000065f,690.921875f,-0.000078f,693.359314f,0.000016f,695.796814f,0.000001f,698.242126f,0.000023f,700.687500f,0.000021f,703.124939f,0.000039f,705.562378f,0.000039f,708.007690f,0.000023f,710.453064f,-0.000018f,712.890503f,0.000030f,715.328003f,0.000002f,717.773315f,-0.000018f,720.218689f,0.000010f,722.656189f,0.000011f,725.093628f,-0.000018f,727.538940f,-0.000023f,729.984375f,-0.000044f,732.421753f,0.000034f,734.859131f,0.000038f,737.304565f,-0.000010f,739.750000f,0.000018f,742.187439f,0.000009f,744.624817f,-0.000021f,747.070190f,-0.000018f,749.515686f,-0.000024f,751.953003f,0.000019f,754.390381f,-0.000006f,756.835815f,0.000023f,759.281250f,0.000023f,761.718628f,0.000041f,764.155945f,0.000012f,766.601440f,0.000034f,769.046997f,-0.000008f,771.484253f,0.000095f,773.921509f,0.000095f,776.367065f,0.000100f,778.812622f,0.000124f,781.249878f,0.000119f,783.687134f,0.000119f,786.132690f,0.000092f,788.578308f,0.000068f,791.015503f,0.000116f,793.452698f,0.000076f,795.898315f,0.000096f,798.343994f,0.000090f,800.781189f,0.000091f,803.218323f,0.000073f,805.663940f,0.000084f,808.109680f,0.000050f,810.546753f,0.000114f,812.983826f,0.000106f,815.429565f,0.000078f,817.875305f,0.000090f,820.312378f,0.000096f,822.749390f,0.000082f,825.195129f,0.000112f,827.640991f,0.000071f,830.077942f,0.000077f,832.514893f,0.000093f,834.960754f,0.000122f,837.406616f,0.000093f,839.843628f,0.000109f,842.280518f,0.000101f,844.726440f,0.000075f,847.172363f,0.000055f,849.609192f,0.000136f,852.046021f,0.000144f,854.492065f,0.000155f,856.938049f,0.000178f,859.374817f,0.000170f,861.811584f,0.000195f,864.257629f,0.000189f,866.703735f,0.000168f,869.140381f,0.000220f,871.577087f,0.000179f,874.023254f,0.000205f,876.469360f,0.000215f,878.906067f,0.000185f,881.342651f,0.000118f,883.788879f,0.000173f,886.235107f,0.000184f,888.671631f,0.000213f,891.108154f,0.000211f,893.554443f,0.000221f,896.000854f,0.000219f,898.437256f,0.000181f,900.873657f,0.000168f,903.320068f,0.000179f,905.766541f,0.000185f,908.202881f,0.000232f,910.639160f,0.000195f,913.085693f,0.000242f,915.532288f,0.000224f,917.968506f,0.000185f,920.404785f,0.000202f,922.851318f,0.000226f,925.298035f,0.000186f,927.734131f,0.000311f,930.170166f,0.000271f,932.616943f,0.000267f,935.063782f,0.000327f,937.499878f,0.000278f,939.935791f,0.000290f,942.382690f,0.000267f,944.829590f,0.000268f,947.265442f,0.000315f,949.701233f,0.000264f,952.148315f,0.000291f,954.595398f,0.000289f,957.031067f,0.000274f,959.466675f,0.000254f,961.913940f,0.000306f,964.361145f,0.000263f,966.796631f,0.000309f,969.232178f,0.000297f,971.679565f,0.000300f,974.126953f,0.000311f,976.562256f,0.000280f,978.997559f,0.000268f,981.445129f,0.000304f,983.892700f,0.000253f,986.327881f,0.000252f,988.763062f,0.000274f,991.210815f,0.000300f,993.658508f,0.000309f,996.093567f,0.000256f,998.528442f,0.000300f,1000.976440f,0.000301f,1003.424438f,0.000294f,1005.859131f,0.000360f,1008.293823f,0.000357f,1010.742065f,0.000389f,1013.190308f,0.000405f,1015.624756f,0.000414f,1018.059204f,0.000430f,1020.507690f,0.000435f,1022.956177f,0.000436f,1025.390381f,0.000479f,1027.824463f,0.000446f,1030.273315f,0.000429f,1032.722046f,0.000471f,1035.156006f,0.000433f,1037.589844f,0.000383f,1040.038940f,0.000466f,1042.488037f,0.000420f,1044.921631f,0.000468f,1047.355225f,0.000480f,1049.804565f,0.000476f,1052.254028f,0.000488f,1054.687256f,0.000440f,1057.120361f,0.000435f,1059.570190f,0.000462f,1062.020020f,0.000480f,1064.452759f,0.000515f,1066.885620f,0.000484f,1069.335815f,0.000538f,1071.786011f,0.000547f,1074.218506f,0.000494f,1076.650757f,0.000499f,1079.101563f,0.000541f,1081.552124f,0.000497f,1083.984009f,0.000552f,1086.415894f,0.000567f,1088.867188f,0.000582f,1091.318359f,0.000582f,1093.749634f,0.000535f,1096.180908f,0.000540f,1098.632813f,0.000577f,1101.084595f,0.000568f,1103.515259f,0.000574f,1105.945923f,0.000584f,1108.398438f,0.000577f,1110.850830f,0.000604f,1113.280884f,0.000538f,1115.710815f,0.000551f,1118.164063f,0.000603f,1120.617310f,0.000557f,1123.046387f,0.000629f,1125.475586f,0.000624f,1127.929688f,0.000649f,1130.383911f,0.000638f,1132.811890f,0.000579f,1135.239990f,0.000595f,1137.695313f,0.000647f,1140.150635f,0.000600f,1142.577393f,0.000636f,1145.004395f,0.000630f,1147.461182f,0.000701f,1149.917480f,0.000694f,1152.343018f,0.000613f,1154.768555f,0.000633f,1157.226807f,0.000661f,1159.684814f,0.000613f,1162.108398f,0.000689f,1164.532471f,0.000707f,1166.992676f,0.000712f,1169.452637f,0.000700f,1171.874023f,0.000715f,1174.295776f,0.000732f,1176.758423f,0.000782f,1179.220703f,0.000757f,1181.639404f,0.000763f,1184.058350f,0.000785f,1186.524292f,0.000791f,1188.989746f,0.000802f,1191.404541f,0.000736f,1193.819946f,0.000704f,1196.290283f,0.000782f,1198.760010f,0.000754f,1201.169556f,0.000780f,1203.579956f,0.000785f,1206.056885f,0.000818f,1208.532593f,0.000813f,1210.934082f,0.000749f,1213.336914f,0.000757f,1215.823975f,0.000829f,1218.309204f,0.000785f,1220.697388f,0.000827f,1223.088013f,0.000793f,1225.593262f,0.000835f,1228.095093f,0.000827f,1230.456787f,0.000759f,1232.823730f,0.000776f,1235.371216f,0.000825f,1237.908936f,0.000807f,1240.193604f,0.000847f,1242.500244f,0.000838f,1245.232422f,0.000882f,1247.869141f,0.000882f,1249.010620f,0.000000f,1247.869507f,0.000008f,1245.232666f,0.000062f,1242.500488f,0.000052f,1240.193970f,0.000038f,1237.909302f,0.000043f,1235.371582f,0.000069f,1232.824097f,0.000077f,1230.457031f,0.000006f,1228.095459f,0.000005f,1225.593628f,0.000059f,1223.088379f,0.000047f,1220.697754f,0.000040f,1218.309570f,0.000070f,1215.824341f,0.000072f,1213.337402f,0.000080f,1210.934448f,0.000020f,1208.532837f,0.000032f,1206.057129f,0.000086f,1203.580200f,0.000058f,1201.169922f,0.000059f,1198.760254f,0.000036f,1196.290771f,0.000065f,1193.820190f,0.000093f,1191.404785f,-0.000019f,1188.989990f,-0.000003f,1186.524536f,0.000045f,1184.058594f,0.000046f,1181.639648f,0.000042f,1179.220947f,0.000055f,1176.758789f,0.000079f,1174.296021f,0.000074f,1171.874268f,0.000034f,1169.452881f,0.000057f,1166.992920f,0.000125f,1164.532715f,0.000101f,1162.108765f,0.000094f,1159.685059f,0.000122f,1157.227051f,0.000152f,1154.768799f,0.000154f,1152.343262f,0.000082f,1149.917725f,0.000057f,1147.461426f,0.000136f,1145.004639f,0.000120f,1142.577637f,0.000091f,1140.150879f,0.000116f,1137.695679f,0.000147f,1135.240356f,0.000129f,1132.812134f,0.000074f,1130.384033f,0.000084f,1127.929932f,0.000138f,1125.475708f,0.000121f,1123.046631f,0.000122f,1120.617554f,0.000107f,1118.164307f,0.000145f,1115.710938f,0.000145f,1113.281006f,0.000077f,1110.851074f,0.000124f,1108.398682f,0.000137f,1105.946167f,0.000151f,1103.515503f,0.000116f,1101.084839f,0.000101f,1098.633057f,0.000129f,1096.181274f,0.000148f,1093.750000f,0.000070f,1091.318604f,0.000072f,1088.867432f,0.000139f,1086.416260f,0.000124f,1083.984375f,0.000080f,1081.552490f,0.000113f,1079.101807f,0.000122f,1076.651123f,0.000134f,1074.218750f,0.000069f,1071.786377f,0.000066f,1069.336182f,0.000113f,1066.885864f,0.000124f,1064.453125f,0.000115f,1062.020386f,0.000134f,1059.570557f,0.000176f,1057.120728f,0.000159f,1054.687500f,0.000092f,1052.254272f,0.000151f,1049.804932f,0.000203f,1047.355469f,0.000165f,1044.921875f,0.000187f,1042.488281f,0.000167f,1040.039307f,0.000215f,1037.590088f,0.000248f,1035.156250f,0.000137f,1032.722412f,0.000170f,1030.273682f,0.000225f,1027.824829f,0.000189f,1025.390625f,0.000156f,1022.956543f,0.000174f,1020.508057f,0.000202f,1018.059570f,0.000184f,1015.625122f,0.000166f,1013.190674f,0.000185f,1010.742432f,0.000245f,1008.294189f,0.000253f,1005.859497f,0.000210f,1003.424805f,0.000248f,1000.976807f,0.000239f,998.528748f,0.000249f,996.093872f,0.000201f,993.658813f,0.000224f,991.211182f,0.000261f,988.763306f,0.000260f,986.328247f,0.000239f,983.893066f,0.000254f,981.445496f,0.000256f,978.997925f,0.000284f,976.562561f,0.000212f,974.127197f,0.000230f,971.679932f,0.000302f,969.232422f,0.000263f,966.796997f,0.000246f,964.361450f,0.000247f,961.914307f,0.000254f,959.466980f,0.000277f,957.031311f,0.000223f,954.595703f,0.000246f,952.148621f,0.000275f,949.701477f,0.000303f,947.265747f,0.000227f,944.829956f,0.000227f,942.382996f,0.000301f,939.936035f,0.000234f,937.500122f,0.000146f,935.064087f,0.000149f,932.617371f,0.000208f,930.170532f,0.000212f,927.734497f,0.000127f,925.298401f,0.000185f,922.851807f,0.000200f,920.405029f,0.000229f,917.968872f,0.000156f,915.532593f,0.000192f,913.086060f,0.000207f,910.639526f,0.000217f,908.203247f,0.000159f,905.766968f,0.000196f,903.320496f,0.000212f,900.874023f,0.000206f,898.437561f,0.000164f,896.001160f,0.000195f,893.554871f,0.000207f,891.108459f,0.000220f,888.671997f,0.000217f,886.235474f,0.000162f,883.789185f,0.000186f,881.342957f,0.000255f,878.906311f,0.000137f,876.469727f,0.000145f,874.023560f,0.000194f,871.577393f,0.000211f,869.140747f,0.000151f,866.704102f,0.000187f,864.257996f,0.000181f,861.811890f,0.000174f,859.375122f,0.000168f,856.938416f,0.000148f,854.492432f,0.000203f,852.046387f,0.000202f,849.609558f,0.000165f,847.172729f,0.000217f,844.726746f,0.000215f,842.280823f,0.000211f,839.843872f,0.000158f,837.406921f,0.000202f,834.961182f,0.000209f,832.515198f,0.000214f,830.078247f,0.000149f,827.641296f,0.000161f,825.195496f,0.000219f,822.749695f,0.000175f,820.312622f,0.000153f,817.875610f,0.000184f,815.429871f,0.000249f,812.984131f,0.000224f,810.546997f,0.000188f,808.109924f,0.000207f,805.664246f,0.000197f,803.218567f,0.000193f,800.781372f,0.000158f,798.344238f,0.000179f,795.898682f,0.000180f,793.452942f,0.000211f,791.015808f,0.000126f,788.578613f,0.000104f,786.133057f,0.000144f,783.687378f,0.000099f,781.250122f,0.000084f,778.812927f,0.000080f,776.367371f,0.000168f,773.921814f,0.000141f,771.484497f,0.000086f,769.047241f,0.000126f,766.601746f,0.000148f,764.156250f,0.000137f,761.718872f,0.000085f,759.281555f,0.000109f,756.836121f,0.000127f,754.390625f,0.000160f,751.953308f,0.000101f,749.515991f,0.000126f,747.070557f,0.000151f,744.625061f,0.000129f,742.187622f,0.000102f,739.750305f,0.000116f,737.304871f,0.000133f,734.859436f,0.000128f,732.422058f,0.000147f,729.984619f,0.000128f,727.539307f,0.000121f,725.093872f,0.000146f,722.656372f,0.000081f,720.218994f,0.000097f,717.773621f,0.000150f,715.328247f,0.000174f,712.890808f,0.000060f,710.453369f,0.000088f,708.008057f,0.000083f,705.562683f,0.000080f,703.125183f,0.000023f,700.687744f,0.000065f,698.242493f,0.000115f,695.797119f,0.000113f,693.359619f,0.000064f,690.922119f,0.000065f,688.476807f,0.000082f,686.031494f,0.000116f,683.593933f,0.000073f,681.156433f,0.000149f,678.711182f,0.000112f,676.265869f,0.000105f,673.828369f,0.000054f,671.390869f,0.000050f,668.945618f,0.000082f,666.500305f,0.000049f,664.062683f,0.000092f,661.625183f,0.000106f,659.179932f,0.000115f,656.734619f,0.000100f,654.297119f,0.000057f,651.859558f,0.000082f,649.414307f,0.000039f,646.969055f,0.000070f,644.531433f,0.000082f,642.093933f,0.000095f,639.648682f,0.000045f,637.203369f,0.000150f,634.765869f,0.000023f,632.328308f,0.000031f,629.883118f,0.000107f,627.437805f,-0.000034f,625.000000f,0.000000f,622.562439f,-0.000035f,620.117249f,0.000076f,617.671936f,0.000060f,615.234375f,-0.000010f,612.796875f,0.000055f,610.351624f,0.000041f,607.906372f,0.000090f,605.468750f,0.000012f,603.031189f,0.000063f,600.585999f,0.000064f,598.140686f,0.000074f,595.703125f,0.000019f,593.265625f,0.000030f,590.820374f,0.000048f,588.375061f,0.000064f,585.937500f,0.000044f,583.500000f,0.000068f,581.054749f,0.000045f,578.609436f,0.000098f,576.171936f,0.000070f,573.734375f,0.000056f,571.289124f,0.000038f,568.843811f,0.000101f,566.406250f,0.000012f,563.968750f,0.000035f,561.523438f,0.000065f,559.078125f,0.000078f,556.640686f,-0.000016f,554.203186f,-0.000001f,551.757874f,-0.000023f,549.312500f,-0.000021f,546.875061f,-0.000039f,544.437622f,-0.000039f,541.992310f,-0.000023f,539.546936f,0.000018f,537.109497f,-0.000030f,534.671997f,-0.000002f,532.226685f,0.000018f,529.781311f,-0.000010f,527.343811f,-0.000011f,524.906372f,0.000018f,522.461060f,0.000023f,520.015625f,0.000044f,517.578247f,-0.000034f,515.140869f,-0.000038f,512.695435f,0.000010f,510.250000f,-0.000018f,507.812561f,-0.000009f,505.375214f,0.000021f,502.929810f,0.000018f,500.484344f,0.000024f,498.047028f,-0.000019f,495.609650f,0.000006f,493.164185f,-0.000023f,490.718719f,-0.000023f,488.281342f,-0.000041f,485.844055f,-0.000012f,483.398560f,-0.000034f,480.953003f,0.000008f,478.515747f,-0.000095f,476.078491f,-0.000095f,473.632935f,-0.000100f,471.187378f,-0.000124f,468.750092f,-0.000119f,466.312866f,-0.000119f,463.867310f,-0.000092f,461.421692f,-0.000068f,458.984497f,-0.000116f,456.547302f,-0.000076f,454.101685f,-0.000096f,451.656006f,-0.000090f,449.218811f,-0.000091f,446.781677f,-0.000073f,444.336029f,-0.000084f,441.890320f,-0.000050f,439.453247f,-0.000114f,437.016174f,-0.000106f,434.570435f,-0.000078f,432.124695f,-0.000090f,429.687622f,-0.000096f,427.250610f,-0.000082f,424.804871f,-0.000112f,422.359009f,-0.000071f,419.922058f,-0.000077f,417.485077f,-0.000093f,415.039246f,-0.000122f,412.593384f,-0.000093f,410.156372f,-0.000109f,407.719513f,-0.000101f,405.273590f,-0.000075f,402.827637f,-0.000055f,400.390808f,-0.000136f,397.953979f,-0.000144f,395.507935f,-0.000155f,393.061951f,-0.000178f,390.625183f,-0.000170f,388.188416f,-0.000195f,385.742371f,-0.000189f,383.296265f,-0.000168f,380.859619f,-0.000220f,378.422913f,-0.000179f,375.976746f,-0.000205f,373.530609f,-0.000215f,371.093933f,-0.000185f,368.657349f,-0.000118f,366.211121f,-0.000173f,363.764893f,-0.000184f,361.328369f,-0.000213f,358.891876f,-0.000211f,356.445526f,-0.000221f,353.999176f,-0.000219f,351.562714f,-0.000181f,349.126312f,-0.000168f,346.679901f,-0.000179f,344.233459f,-0.000185f,341.797150f,-0.000232f,339.360840f,-0.000195f,336.914276f,-0.000242f,334.467712f,-0.000224f,332.031464f,-0.000185f,329.595245f,-0.000202f,327.148651f,-0.000226f,324.701965f,-0.000186f,322.265900f,-0.000311f,319.829803f,-0.000271f,317.383026f,-0.000267f,314.936218f,-0.000327f,312.500153f,-0.000278f,310.064240f,-0.000290f,307.617310f,-0.000267f,305.170410f,-0.000268f,302.734558f,-0.000315f,300.298767f,-0.000264f,297.851654f,-0.000291f,295.404602f,-0.000289f,292.968933f,-0.000274f,290.533295f,-0.000254f,288.086090f,-0.000306f,285.638855f,-0.000263f,283.203339f,-0.000309f,280.767853f,-0.000297f,278.320435f,-0.000300f,275.873077f,-0.000311f,273.437714f,-0.000280f,271.002411f,-0.000268f,268.554871f,-0.000304f,266.107300f,-0.000253f,263.672150f,-0.000252f,261.236969f,-0.000274f,258.789185f,-0.000300f,256.341492f,-0.000309f,253.906433f,-0.000256f,251.471588f,-0.000300f,249.023529f,-0.000301f,246.575562f,-0.000294f,244.140869f,-0.000360f,241.706146f,-0.000357f,239.257904f,-0.000389f,236.809662f,-0.000405f,234.375244f,-0.000414f,231.940765f,-0.000430f,229.492310f,-0.000435f,227.043854f,-0.000436f,224.609650f,-0.000479f,222.175476f,-0.000446f,219.726685f,-0.000429f,217.277954f,-0.000471f,214.843994f,-0.000433f,212.410126f,-0.000383f,209.961060f,-0.000466f,207.511993f,-0.000420f,205.078400f,-0.000468f,202.644806f,-0.000480f,200.195435f,-0.000476f,197.746002f,-0.000488f,195.312775f,-0.000440f,192.879608f,-0.000435f,190.429810f,-0.000462f,187.980011f,-0.000480f,185.547241f,-0.000515f,183.114380f,-0.000484f,180.664185f,-0.000538f,178.213989f,-0.000547f,175.781555f,-0.000494f,173.349213f,-0.000499f,170.898499f,-0.000541f,168.447876f,-0.000497f,166.015961f,-0.000552f,163.584076f,-0.000567f,161.132843f,-0.000582f,158.681671f,-0.000582f,156.250336f,-0.000535f,153.819031f,-0.000540f,151.367188f,-0.000577f,148.915405f,-0.000568f,146.484772f,-0.000574f,144.054077f,-0.000584f,141.601532f,-0.000577f,139.149139f,-0.000604f,136.719147f,-0.000538f,134.289215f,-0.000551f,131.835938f,-0.000603f,129.382660f,-0.000557f,126.953644f,-0.000629f,124.524475f,-0.000624f,122.070251f,-0.000649f,119.616119f,-0.000638f,117.188080f,-0.000579f,114.759949f,-0.000595f,112.304626f,-0.000647f,109.849426f,-0.000600f,107.422607f,-0.000636f,104.995544f,-0.000630f,102.538879f,-0.000701f,100.082458f,-0.000694f,97.656982f,-0.000613f,95.231384f,-0.000633f,92.773193f,-0.000661f,90.315186f,-0.000613f,87.891541f,-0.000689f,85.467590f,-0.000707f,83.007385f,-0.000712f,80.547424f,-0.000700f,78.125977f,-0.000715f,75.704224f,-0.000732f,73.241577f,-0.000782f,70.779297f,-0.000757f,68.360596f,-0.000763f,65.941589f,-0.000785f,63.475708f,-0.000791f,61.010315f,-0.000802f,58.595398f,-0.000736f,56.180054f,-0.000704f,53.709656f,-0.000782f,51.239990f,-0.000754f,48.830444f,-0.000780f,46.420044f,-0.000785f,43.943176f,-0.000818f,41.467407f,-0.000813f,39.065857f,-0.000749f,36.663086f,-0.000757f,34.176086f,-0.000829f,31.690796f,-0.000785f,29.302612f,-0.000827f,26.911987f,-0.000793f,24.406738f,-0.000835f,21.904907f,-0.000827f,19.543274f,-0.000759f,17.176270f,-0.000776f,14.628784f,-0.000825f,12.091125f,-0.000807f,9.806335f,-0.000847f,7.499695f,-0.000838f,4.767578f,-0.000882f,2.130798f,-0.000882f};
/* 512 filter array */
float FFT_filter [] = {0.989380f,2.130493f,4.767273f,7.499451f,9.806030f,12.090698f,14.628357f,17.175903f,19.542908f,21.904541f,24.406372f,26.911682f,29.302185f,31.690369f,34.175659f,36.662659f,39.065552f,41.467163f,43.942932f,46.419800f,48.830139f,51.239685f,53.709290f,56.179810f,58.595154f,61.009949f,63.475464f,65.941406f,68.360413f,70.778992f,73.241272f,75.703979f,78.125793f,80.547180f,83.007141f,85.467285f,87.891235f,90.314880f,92.772888f,95.231140f,97.656738f,100.082214f,102.538574f,104.995300f,107.422302f,109.849121f,112.304321f,114.759674f,117.187866f,119.615936f,122.070068f,124.524292f,126.953430f,129.382446f,131.835632f,134.289001f,136.718964f,139.148895f,141.601318f,144.053833f,146.484497f,148.915131f,151.366882f,153.818695f,156.250061f,158.681335f,161.132538f,163.583801f,166.015656f,168.447510f,170.898163f,173.348907f,175.781281f,178.213654f,180.663849f,183.114105f,185.546906f,187.979614f,190.429413f,192.879242f,195.312531f,197.745728f,200.195099f,202.644592f,205.078186f,207.511688f,209.960693f,212.409851f,214.843750f,217.277649f,219.726349f,222.175171f,224.609314f,227.043457f,229.491913f,231.940430f,234.374908f,236.809357f,239.257568f,241.705841f,244.140533f,246.575226f,249.023193f,251.471252f,253.906158f,256.341156f,258.788849f,261.236694f,263.671783f,266.106903f,268.554504f,271.002075f,273.437439f,275.872772f,278.320099f,280.767578f,283.203033f,285.638550f,288.085724f,290.533020f,292.968689f,295.404327f,297.851379f,300.298523f,302.734283f,305.170074f,307.617004f,310.063934f,312.499908f,314.935883f,317.382629f,319.829468f,322.265533f,324.701599f,327.148224f,329.594940f,332.031158f,334.467377f,336.913910f,339.360504f,341.796783f,344.233063f,346.679504f,349.125977f,351.562439f,353.998840f,356.445129f,358.891541f,361.328033f,363.764557f,366.210785f,368.657043f,371.093689f,373.530304f,375.976410f,378.422607f,380.859253f,383.295929f,385.742004f,388.188080f,390.624878f,393.061584f,395.507568f,397.953644f,400.390442f,402.827271f,405.273254f,407.719177f,410.156128f,412.593079f,415.038849f,417.484802f,419.921753f,422.358704f,424.804504f,427.250305f,429.687378f,432.124420f,434.570129f,437.015900f,439.453003f,441.890076f,444.335754f,446.781433f,449.218628f,451.655762f,454.101349f,456.547058f,458.984192f,461.421387f,463.866943f,466.312592f,468.749847f,471.187073f,473.632629f,476.078186f,478.515472f,480.952728f,483.398254f,485.843781f,488.281128f,490.718445f,493.163879f,495.609406f,498.046692f,500.484039f,502.929443f,505.374939f,507.812378f,510.249695f,512.695129f,515.140564f,517.577942f,520.015381f,522.460693f,524.906128f,527.343628f,529.781006f,532.226379f,534.671753f,537.109192f,539.546631f,541.991943f,544.437317f,546.874817f,549.312256f,551.757507f,554.202881f,556.640381f,559.077881f,561.523193f,563.968506f,566.406067f,568.843567f,571.288818f,573.734131f,576.171631f,578.609131f,581.054382f,583.499695f,585.937317f,588.374817f,590.820068f,593.265381f,595.702881f,598.140442f,600.585693f,603.030945f,605.468567f,607.906067f,610.351318f,612.796631f,615.234131f,617.671692f,620.116882f,622.562195f,625.000000f,627.437561f,629.882751f,632.328064f,634.765625f,637.203125f,639.648376f,642.093628f,644.531250f,646.968811f,649.414001f,651.859314f,654.296875f,656.734375f,659.179626f,661.624939f,664.062500f,666.500000f,668.945251f,671.390564f,673.828064f,676.265625f,678.710876f,681.156189f,683.593750f,686.031250f,688.476563f,690.921875f,693.359314f,695.796814f,698.242126f,700.687500f,703.124939f,705.562378f,708.007690f,710.453064f,712.890503f,715.328003f,717.773315f,720.218689f,722.656189f,725.093628f,727.538940f,729.984375f,732.421753f,734.859131f,737.304565f,739.750000f,742.187439f,744.624817f,747.070190f,749.515686f,751.953003f,754.390381f,756.835815f,759.281250f,761.718628f,764.155945f,766.601440f,769.046997f,771.484253f,773.921509f,776.367065f,778.812622f,781.249878f,783.687134f,786.132690f,788.578308f,791.015503f,793.452698f,795.898315f,798.343994f,800.781189f,803.218323f,805.663940f,808.109680f,810.546753f,812.983826f,815.429565f,817.875305f,820.312378f,822.749390f,825.195129f,827.640991f,830.077942f,832.514893f,834.960754f,837.406616f,839.843628f,842.280518f,844.726440f,847.172363f,849.609192f,852.046021f,854.492065f,856.938049f,859.374817f,861.811584f,864.257629f,866.703735f,869.140381f,871.577087f,874.023254f,876.469360f,878.906067f,881.342651f,883.788879f,886.235107f,888.671631f,891.108154f,893.554443f,896.000854f,898.437256f,900.873657f,903.320068f,905.766541f,908.202881f,910.639160f,913.085693f,915.532288f,917.968506f,920.404785f,922.851318f,925.298035f,927.734131f,930.170166f,932.616943f,935.063782f,937.499878f,939.935791f,942.382690f,944.829590f,947.265442f,949.701233f,952.148315f,954.595398f,957.031067f,959.466675f,961.913940f,964.361145f,966.796631f,969.232178f,971.679565f,974.126953f,976.562256f,978.997559f,981.445129f,983.892700f,986.327881f,988.763062f,991.210815f,993.658508f,996.093567f,998.528442f,1000.976440f,1003.424438f,1005.859131f,1008.293823f,1010.742065f,1013.190308f,1015.624756f,1018.059204f,1020.507690f,1022.956177f,1025.390381f,1027.824463f,1030.273315f,1032.722046f,1035.156006f,1037.589844f,1040.038940f,1042.488037f,1044.921631f,1047.355225f,1049.804565f,1052.254028f,1054.687256f,1057.120361f,1059.570190f,1062.020020f,1064.452759f,1066.885620f,1069.335815f,1071.786011f,1074.218506f,1076.650757f,1079.101563f,1081.552124f,1083.984009f,1086.415894f,1088.867188f,1091.318359f,1093.749634f,1096.180908f,1098.632813f,1101.084595f,1103.515259f,1105.945923f,1108.398438f,1110.850830f,1113.280884f,1115.710815f,1118.164063f,1120.617310f,1123.046387f,1125.475586f,1127.929688f,1130.383911f,1132.811890f,1135.239990f,1137.695313f,1140.150635f,1142.577393f,1145.004395f,1147.461182f,1149.917480f,1152.343018f,1154.768555f,1157.226807f,1159.684814f,1162.108398f,1164.532471f,1166.992676f,1169.452637f,1171.874023f,1174.295776f,1176.758423f,1179.220703f,1181.639404f,1184.058350f,1186.524292f,1188.989746f,1191.404541f,1193.819946f,1196.290283f,1198.760010f,1201.169556f,1203.579956f,1206.056885f,1208.532593f,1210.934082f,1213.336914f,1215.823975f,1218.309204f,1220.697388f,1223.088013f,1225.593262f,1228.095093f,1230.456787f,1232.823730f,1235.371216f,1237.908936f,1240.193604f,1242.500244f,1245.232422f,1247.869141f,1249.010620f,1247.869507f,1245.232666f,1242.500488f,1240.193970f,1237.909302f,1235.371582f,1232.824097f,1230.457031f,1228.095459f,1225.593628f,1223.088379f,1220.697754f,1218.309570f,1215.824341f,1213.337402f,1210.934448f,1208.532837f,1206.057129f,1203.580200f,1201.169922f,1198.760254f,1196.290771f,1193.820190f,1191.404785f,1188.989990f,1186.524536f,1184.058594f,1181.639648f,1179.220947f,1176.758789f,1174.296021f,1171.874268f,1169.452881f,1166.992920f,1164.532715f,1162.108765f,1159.685059f,1157.227051f,1154.768799f,1152.343262f,1149.917725f,1147.461426f,1145.004639f,1142.577637f,1140.150879f,1137.695679f,1135.240356f,1132.812134f,1130.384033f,1127.929932f,1125.475708f,1123.046631f,1120.617554f,1118.164307f,1115.710938f,1113.281006f,1110.851074f,1108.398682f,1105.946167f,1103.515503f,1101.084839f,1098.633057f,1096.181274f,1093.750000f,1091.318604f,1088.867432f,1086.416260f,1083.984375f,1081.552490f,1079.101807f,1076.651123f,1074.218750f,1071.786377f,1069.336182f,1066.885864f,1064.453125f,1062.020386f,1059.570557f,1057.120728f,1054.687500f,1052.254272f,1049.804932f,1047.355469f,1044.921875f,1042.488281f,1040.039307f,1037.590088f,1035.156250f,1032.722412f,1030.273682f,1027.824829f,1025.390625f,1022.956543f,1020.508057f,1018.059570f,1015.625122f,1013.190674f,1010.742432f,1008.294189f,1005.859497f,1003.424805f,1000.976807f,998.528748f,996.093872f,993.658813f,991.211182f,988.763306f,986.328247f,983.893066f,981.445496f,978.997925f,976.562561f,974.127197f,971.679932f,969.232422f,966.796997f,964.361450f,961.914307f,959.466980f,957.031311f,954.595703f,952.148621f,949.701477f,947.265747f,944.829956f,942.382996f,939.936035f,937.500122f,935.064087f,932.617371f,930.170532f,927.734497f,925.298401f,922.851807f,920.405029f,917.968872f,915.532593f,913.086060f,910.639526f,908.203247f,905.766968f,903.320496f,900.874023f,898.437561f,896.001160f,893.554871f,891.108459f,888.671997f,886.235474f,883.789185f,881.342957f,878.906311f,876.469727f,874.023560f,871.577393f,869.140747f,866.704102f,864.257996f,861.811890f,859.375122f,856.938416f,854.492432f,852.046387f,849.609558f,847.172729f,844.726746f,842.280823f,839.843872f,837.406921f,834.961182f,832.515198f,830.078247f,827.641296f,825.195496f,822.749695f,820.312622f,817.875610f,815.429871f,812.984131f,810.546997f,808.109924f,805.664246f,803.218567f,800.781372f,798.344238f,795.898682f,793.452942f,791.015808f,788.578613f,786.133057f,783.687378f,781.250122f,778.812927f,776.367371f,773.921814f,771.484497f,769.047241f,766.601746f,764.156250f,761.718872f,759.281555f,756.836121f,754.390625f,751.953308f,749.515991f,747.070557f,744.625061f,742.187622f,739.750305f,737.304871f,734.859436f,732.422058f,729.984619f,727.539307f,725.093872f,722.656372f,720.218994f,717.773621f,715.328247f,712.890808f,710.453369f,708.008057f,705.562683f,703.125183f,700.687744f,698.242493f,695.797119f,693.359619f,690.922119f,688.476807f,686.031494f,683.593933f,681.156433f,678.711182f,676.265869f,673.828369f,671.390869f,668.945618f,666.500305f,664.062683f,661.625183f,659.179932f,656.734619f,654.297119f,651.859558f,649.414307f,646.969055f,644.531433f,642.093933f,639.648682f,637.203369f,634.765869f,632.328308f,629.883118f,627.437805f,625.000000f,622.562439f,620.117249f,617.671936f,615.234375f,612.796875f,610.351624f,607.906372f,605.468750f,603.031189f,600.585999f,598.140686f,595.703125f,593.265625f,590.820374f,588.375061f,585.937500f,583.500000f,581.054749f,578.609436f,576.171936f,573.734375f,571.289124f,568.843811f,566.406250f,563.968750f,561.523438f,559.078125f,556.640686f,554.203186f,551.757874f,549.312500f,546.875061f,544.437622f,541.992310f,539.546936f,537.109497f,534.671997f,532.226685f,529.781311f,527.343811f,524.906372f,522.461060f,520.015625f,517.578247f,515.140869f,512.695435f,510.250000f,507.812561f,505.375214f,502.929810f,500.484344f,498.047028f,495.609650f,493.164185f,490.718719f,488.281342f,485.844055f,483.398560f,480.953003f,478.515747f,476.078491f,473.632935f,471.187378f,468.750092f,466.312866f,463.867310f,461.421692f,458.984497f,456.547302f,454.101685f,451.656006f,449.218811f,446.781677f,444.336029f,441.890320f,439.453247f,437.016174f,434.570435f,432.124695f,429.687622f,427.250610f,424.804871f,422.359009f,419.922058f,417.485077f,415.039246f,412.593384f,410.156372f,407.719513f,405.273590f,402.827637f,400.390808f,397.953979f,395.507935f,393.061951f,390.625183f,388.188416f,385.742371f,383.296265f,380.859619f,378.422913f,375.976746f,373.530609f,371.093933f,368.657349f,366.211121f,363.764893f,361.328369f,358.891876f,356.445526f,353.999176f,351.562714f,349.126312f,346.679901f,344.233459f,341.797150f,339.360840f,336.914276f,334.467712f,332.031464f,329.595245f,327.148651f,324.701965f,322.265900f,319.829803f,317.383026f,314.936218f,312.500153f,310.064240f,307.617310f,305.170410f,302.734558f,300.298767f,297.851654f,295.404602f,292.968933f,290.533295f,288.086090f,285.638855f,283.203339f,280.767853f,278.320435f,275.873077f,273.437714f,271.002411f,268.554871f,266.107300f,263.672150f,261.236969f,258.789185f,256.341492f,253.906433f,251.471588f,249.023529f,246.575562f,244.140869f,241.706146f,239.257904f,236.809662f,234.375244f,231.940765f,229.492310f,227.043854f,224.609650f,222.175476f,219.726685f,217.277954f,214.843994f,212.410126f,209.961060f,207.511993f,205.078400f,202.644806f,200.195435f,197.746002f,195.312775f,192.879608f,190.429810f,187.980011f,185.547241f,183.114380f,180.664185f,178.213989f,175.781555f,173.349213f,170.898499f,168.447876f,166.015961f,163.584076f,161.132843f,158.681671f,156.250336f,153.819031f,151.367188f,148.915405f,146.484772f,144.054077f,141.601532f,139.149139f,136.719147f,134.289215f,131.835938f,129.382660f,126.953644f,124.524475f,122.070251f,119.616119f,117.188080f,114.759949f,112.304626f,109.849426f,107.422607f,104.995544f,102.538879f,100.082458f,97.656982f,95.231384f,92.773193f,90.315186f,87.891541f,85.467590f,83.007385f,80.547424f,78.125977f,75.704224f,73.241577f,70.779297f,68.360596f,65.941589f,63.475708f,61.010315f,58.595398f,56.180054f,53.709656f,51.239990f,48.830444f,46.420044f,43.943176f,41.467407f,39.065857f,36.663086f,34.176086f,31.690796f,29.302612f,26.911987f,24.406738f,21.904907f,19.543274f,17.176270f,14.628784f,12.091125f,9.806335f,7.499695f,4.767578f,2.130798f};

/* 256 swiching sheet */
unsigned int switchingsheet_256[] = {0, 1025, 513, 1537, 257, 1281, 769, 1793, 129, 1153, 641, 1665, 385, 1409, 897, 1921, 65, 1089, 577, 1601, 321, 1345, 833, 1857, 193, 1217, 705, 1729, 449, 1473, 961, 1985, 0, 1057, 545, 1569, 289, 1313, 801, 1825, 161, 1185, 673, 1697, 417, 1441, 929, 1953, 0, 1121, 609, 1633, 353, 1377, 865, 1889, 225, 1249, 737, 1761, 481, 1505, 993, 2017, 0, 1041, 529, 1553, 273, 1297, 785, 1809, 0, 1169, 657, 1681, 401, 1425, 913, 1937, 0, 1105, 593, 1617, 337, 1361, 849, 1873, 209, 1233, 721, 1745, 465, 1489, 977, 2001, 0, 1073, 561, 1585, 305, 1329, 817, 1841, 0, 1201, 689, 1713, 433, 1457, 945, 1969, 0, 1137, 625, 1649, 369, 1393, 881, 1905, 0, 1265, 753, 1777, 497, 1521, 1009, 2033, 0, 1033, 521, 1545, 0, 1289, 777, 1801, 0, 1161, 649, 1673, 393, 1417, 905, 1929, 0, 1097, 585, 1609, 329, 1353, 841, 1865, 0, 1225, 713, 1737, 457, 1481, 969, 1993, 0, 1065, 553, 1577, 0, 1321, 809, 1833, 0, 1193, 681, 1705, 425, 1449, 937, 1961, 0, 1129, 617, 1641, 0, 1385, 873, 1897, 0, 1257, 745, 1769, 489, 1513, 1001, 2025, 0, 1049, 537, 1561, 0, 1305, 793, 1817, 0, 1177, 665, 1689, 0, 1433, 921, 1945, 0, 1113, 601, 1625, 0, 1369, 857, 1881, 0, 1241, 729, 1753, 473, 1497, 985, 2009, 0, 1081, 569, 1593, 0, 1337, 825, 1849, 0, 1209, 697, 1721, 0, 1465, 953, 1977, 0, 1145, 633, 1657, 0, 1401, 889, 1913, 0, 1273, 761, 1785, 0, 1529, 1017, 2041, 0, 1029, 0, 1541, 0, 1285, 773, 1797, 0, 1157, 645, 1669, 0, 1413, 901, 1925, 0, 1093, 581, 1605, 0, 1349, 837, 1861, 0, 1221, 709, 1733, 0, 1477, 965, 1989, 0, 1061, 0, 1573, 0, 1317, 805, 1829, 0, 1189, 677, 1701, 0, 1445, 933, 1957, 0, 1125, 0, 1637, 0, 1381, 869, 1893, 0, 1253, 741, 1765, 0, 1509, 997, 2021, 0, 1045, 0, 1557, 0, 1301, 789, 1813, 0, 1173, 0, 1685, 0, 1429, 917, 1941, 0, 1109, 0, 1621, 0, 1365, 853, 1877, 0, 1237, 725, 1749, 0, 1493, 981, 2005, 0, 1077, 0, 1589, 0, 1333, 821, 1845, 0, 1205, 0, 1717, 0, 1461, 949, 1973, 0, 1141, 0, 1653, 0, 1397, 885, 1909, 0, 1269, 0, 1781, 0, 1525, 1013, 2037, 0, 1037, 0, 1549, 0, 1293, 0, 1805, 0, 1165, 0, 1677, 0, 1421, 909, 1933, 0, 1101, 0, 1613, 0, 1357, 845, 1869, 0, 1229, 0, 1741, 0, 1485, 973, 1997, 0, 1069, 0, 1581, 0, 1325, 0, 1837, 0, 1197, 0, 1709, 0, 1453, 941, 1965, 0, 1133, 0, 1645, 0, 1389, 0, 1901, 0, 1261, 0, 1773, 0, 1517, 1005, 2029, 0, 1053, 0, 1565, 0, 1309, 0, 1821, 0, 1181, 0, 1693, 0, 1437, 0, 1949, 0, 1117, 0, 1629, 0, 1373, 0, 1885, 0, 1245, 0, 1757, 0, 1501, 989, 2013, 0, 1085, 0, 1597, 0, 1341, 0, 1853, 0, 1213, 0, 1725, 0, 1469, 0, 1981, 0, 1149, 0, 1661, 0, 1405, 0, 1917, 0, 1277, 0, 1789, 0, 1533, 0, 2045, 0, 0, 0, 1539, 0, 1283, 0, 1795, 0, 1155, 0, 1667, 0, 1411, 0, 1923, 0, 1091, 0, 1603, 0, 1347, 0, 1859, 0, 1219, 0, 1731, 0, 1475, 0, 1987, 0, 0, 0, 1571, 0, 1315, 0, 1827, 0, 1187, 0, 1699, 0, 1443, 0, 1955, 0, 0, 0, 1635, 0, 1379, 0, 1891, 0, 1251, 0, 1763, 0, 1507, 0, 2019, 0, 0, 0, 1555, 0, 1299, 0, 1811, 0, 0, 0, 1683, 0, 1427, 0, 1939, 0, 0, 0, 1619, 0, 1363, 0, 1875, 0, 1235, 0, 1747, 0, 1491, 0, 2003, 0, 0, 0, 1587, 0, 1331, 0, 1843, 0, 0, 0, 1715, 0, 1459, 0, 1971, 0, 0, 0, 1651, 0, 1395, 0, 1907, 0, 0, 0, 1779, 0, 1523, 0, 2035, 0, 0, 0, 1547, 0, 0, 0, 1803, 0, 0, 0, 1675, 0, 1419, 0, 1931, 0, 0, 0, 1611, 0, 1355, 0, 1867, 0, 0, 0, 1739, 0, 1483, 0, 1995, 0, 0, 0, 1579, 0, 0, 0, 1835, 0, 0, 0, 1707, 0, 1451, 0, 1963, 0, 0, 0, 1643, 0, 0, 0, 1899, 0, 0, 0, 1771, 0, 1515, 0, 2027, 0, 0, 0, 1563, 0, 0, 0, 1819, 0, 0, 0, 1691, 0, 0, 0, 1947, 0, 0, 0, 1627, 0, 0, 0, 1883, 0, 0, 0, 1755, 0, 1499, 0, 2011, 0, 0, 0, 1595, 0, 0, 0, 1851, 0, 0, 0, 1723, 0, 0, 0, 1979, 0, 0, 0, 1659, 0, 0, 0, 1915, 0, 0, 0, 1787, 0, 0, 0, 2043, 0, 0, 0, 0, 0, 0, 0, 1799, 0, 0, 0, 1671, 0, 0, 0, 1927, 0, 0, 0, 1607, 0, 0, 0, 1863, 0, 0, 0, 1735, 0, 0, 0, 1991, 0, 0, 0, 0, 0, 0, 0, 1831, 0, 0, 0, 1703, 0, 0, 0, 1959, 0, 0, 0, 0, 0, 0, 0, 1895, 0, 0, 0, 1767, 0, 0, 0, 2023, 0, 0, 0, 0, 0, 0, 0, 1815, 0, 0, 0, 0, 0, 0, 0, 1943, 0, 0, 0, 0, 0, 0, 0, 1879, 0, 0, 0, 1751, 0, 0, 0, 2007, 0, 0, 0, 0, 0, 0, 0, 1847, 0, 0, 0, 0, 0, 0, 0, 1975, 0, 0, 0, 0, 0, 0, 0, 1911, 0, 0, 0, 0, 0, 0, 0, 2039, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1935, 0, 0, 0, 0, 0, 0, 0, 1871, 0, 0, 0, 0, 0, 0, 0, 1999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1967, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2031, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2015};

/* 512 swiching sheet */
unsigned int switchingsheet[] = {
    0, 2049, 1025, 3073, 513, 2561, 1537, 3585, 257, 2305, 1281, 3329,  769, 2817, 1793, 3841 ,                        
 129, 2177, 1153, 3201, 641, 2689, 1665, 3713, 385, 2433, 1409, 3457,  897, 2945, 1921, 3969 ,                        
   0, 2113, 1089, 3137, 577, 2625, 1601, 3649, 321, 2369, 1345, 3393,  833, 2881, 1857, 3905 ,                        
 193, 2241, 1217, 3265, 705, 2753, 1729, 3777, 449, 2497, 1473, 3521,  961, 3009, 1985, 4033 ,                        
   0, 2081, 1057, 3105, 545, 2593, 1569, 3617, 289, 2337, 1313, 3361,  801, 2849, 1825, 3873 ,                        
   0, 2209, 1185, 3233, 673, 2721, 1697, 3745, 417, 2465, 1441, 3489,  929, 2977, 1953, 4001 ,                        
   0, 2145, 1121, 3169, 609, 2657, 1633, 3681, 353, 2401, 1377, 3425,  865, 2913, 1889, 3937 ,                        
   0, 2273, 1249, 3297, 737, 2785, 1761, 3809, 481, 2529, 1505, 3553,  993, 3041, 2017, 4065 ,                        
   0, 2065, 1041, 3089, 529, 2577, 1553, 3601,   0, 2321, 1297, 3345,  785, 2833, 1809, 3857 ,                        
   0, 2193, 1169, 3217, 657, 2705, 1681, 3729, 401, 2449, 1425, 3473,  913, 2961, 1937, 3985 ,                        
   0, 2129, 1105, 3153, 593, 2641, 1617, 3665,   0, 2385, 1361, 3409,  849, 2897, 1873, 3921 ,                        
   0, 2257, 1233, 3281, 721, 2769, 1745, 3793, 465, 2513, 1489, 3537,  977, 3025, 2001, 4049 ,                        
   0, 2097, 1073, 3121, 561, 2609, 1585, 3633,   0, 2353, 1329, 3377,  817, 2865, 1841, 3889 ,                        
   0, 2225, 1201, 3249, 689, 2737, 1713, 3761,   0, 2481, 1457, 3505,  945, 2993, 1969, 4017 ,                        
   0, 2161, 1137, 3185, 625, 2673, 1649, 3697,   0, 2417, 1393, 3441,  881, 2929, 1905, 3953 ,                        
   0, 2289, 1265, 3313, 753, 2801, 1777, 3825,   0, 2545, 1521, 3569, 1009, 3057, 2033, 4081 ,                        
   0, 2057, 1033, 3081,   0, 2569, 1545, 3593,   0, 2313, 1289, 3337,  777, 2825, 1801, 3849 ,                        
   0, 2185, 1161, 3209, 649, 2697, 1673, 3721,   0, 2441, 1417, 3465,  905, 2953, 1929, 3977 ,                        
   0, 2121, 1097, 3145,   0, 2633, 1609, 3657,   0, 2377, 1353, 3401,  841, 2889, 1865, 3913 ,                        
   0, 2249, 1225, 3273, 713, 2761, 1737, 3785,   0, 2505, 1481, 3529,  969, 3017, 1993, 4041 ,                        
   0, 2089, 1065, 3113,   0, 2601, 1577, 3625,   0, 2345, 1321, 3369,  809, 2857, 1833, 3881 ,                        
   0, 2217, 1193, 3241,   0, 2729, 1705, 3753,   0, 2473, 1449, 3497,  937, 2985, 1961, 4009 ,                        
   0, 2153, 1129, 3177,   0, 2665, 1641, 3689,   0, 2409, 1385, 3433,  873, 2921, 1897, 3945 ,                        
   0, 2281, 1257, 3305,   0, 2793, 1769, 3817,   0, 2537, 1513, 3561, 1001, 3049, 2025, 4073 ,                        
   0, 2073, 1049, 3097,   0, 2585, 1561, 3609,   0, 2329, 1305, 3353,    0, 2841, 1817, 3865 ,                        
   0, 2201, 1177, 3225,   0, 2713, 1689, 3737,   0, 2457, 1433, 3481,  921, 2969, 1945, 3993 ,                        
   0, 2137, 1113, 3161,   0, 2649, 1625, 3673,   0, 2393, 1369, 3417,    0, 2905, 1881, 3929 ,                        
   0, 2265, 1241, 3289,   0, 2777, 1753, 3801,   0, 2521, 1497, 3545,  985, 3033, 2009, 4057 ,                        
   0, 2105, 1081, 3129,   0, 2617, 1593, 3641,   0, 2361, 1337, 3385,    0, 2873, 1849, 3897 ,                        
   0, 2233, 1209, 3257,   0, 2745, 1721, 3769,   0, 2489, 1465, 3513,    0, 3001, 1977, 4025 ,                        
   0, 2169, 1145, 3193,   0, 2681, 1657, 3705,   0, 2425, 1401, 3449,    0, 2937, 1913, 3961 ,                        
   0, 2297, 1273, 3321,   0, 2809, 1785, 3833,   0, 2553, 1529, 3577,    0, 3065, 2041, 4089 ,                        
   0, 2053,    0, 3077,   0, 2565, 1541, 3589,   0, 2309, 1285, 3333,    0, 2821, 1797, 3845 ,                        
   0, 2181, 1157, 3205,   0, 2693, 1669, 3717,   0, 2437, 1413, 3461,    0, 2949, 1925, 3973 ,                        
   0, 2117,    0, 3141,   0, 2629, 1605, 3653,   0, 2373, 1349, 3397,    0, 2885, 1861, 3909 ,                        
   0, 2245, 1221, 3269,   0, 2757, 1733, 3781,   0, 2501, 1477, 3525,    0, 3013, 1989, 4037 ,                        
   0, 2085,    0, 3109,   0, 2597, 1573, 3621,   0, 2341, 1317, 3365,    0, 2853, 1829, 3877 ,                        
   0, 2213,    0, 3237,   0, 2725, 1701, 3749,   0, 2469, 1445, 3493,    0, 2981, 1957, 4005 ,                        
   0, 2149,    0, 3173,   0, 2661, 1637, 3685,   0, 2405, 1381, 3429,    0, 2917, 1893, 3941 ,                        
   0, 2277,    0, 3301,   0, 2789, 1765, 3813,   0, 2533, 1509, 3557,    0, 3045, 2021, 4069 ,                        
   0, 2069,    0, 3093,   0, 2581, 1557, 3605,   0, 2325,    0, 3349,    0, 2837, 1813, 3861 ,                        
   0, 2197,    0, 3221,   0, 2709, 1685, 3733,   0, 2453, 1429, 3477,    0, 2965, 1941, 3989 ,                        
   0, 2133,    0, 3157,   0, 2645, 1621, 3669,   0, 2389,    0, 3413,    0, 2901, 1877, 3925 ,                        
   0, 2261,    0, 3285,   0, 2773, 1749, 3797,   0, 2517, 1493, 3541,    0, 3029, 2005, 4053 ,                        
   0, 2101,    0, 3125,   0, 2613, 1589, 3637,   0, 2357,    0, 3381,    0, 2869, 1845, 3893 ,                        
   0, 2229,    0, 3253,   0, 2741, 1717, 3765,   0, 2485,    0, 3509,    0, 2997, 1973, 4021 ,                        
   0, 2165,    0, 3189,   0, 2677, 1653, 3701,   0, 2421,    0, 3445,    0, 2933, 1909, 3957 ,                        
   0, 2293,    0, 3317,   0, 2805, 1781, 3829,   0, 2549,    0, 3573,    0, 3061, 2037, 4085 ,                        
   0, 2061,    0, 3085,   0, 2573,    0, 3597,   0, 2317,    0, 3341,    0, 2829, 1805, 3853 ,                        
   0, 2189,    0, 3213,   0, 2701, 1677, 3725,   0, 2445,    0, 3469,    0, 2957, 1933, 3981 ,                        
   0, 2125,    0, 3149,   0, 2637,    0, 3661,   0, 2381,    0, 3405,    0, 2893, 1869, 3917 ,                        
   0, 2253,    0, 3277,   0, 2765, 1741, 3789,   0, 2509,    0, 3533,    0, 3021, 1997, 4045 ,                        
   0, 2093,    0, 3117,   0, 2605,    0, 3629,   0, 2349,    0, 3373,    0, 2861, 1837, 3885 ,                        
   0, 2221,    0, 3245,   0, 2733,    0, 3757,   0, 2477,    0, 3501,    0, 2989, 1965, 4013 ,                        
   0, 2157,    0, 3181,   0, 2669,    0, 3693,   0, 2413,    0, 3437,    0, 2925, 1901, 3949 ,                        
   0, 2285,    0, 3309,   0, 2797,    0, 3821,   0, 2541,    0, 3565,    0, 3053, 2029, 4077 ,                        
   0, 2077,    0, 3101,   0, 2589,    0, 3613,   0, 2333,    0, 3357,    0, 2845,    0, 3869 ,                        
   0, 2205,    0, 3229,   0, 2717,    0, 3741,   0, 2461,    0, 3485,    0, 2973, 1949, 3997 ,                        
   0, 2141,    0, 3165,   0, 2653,    0, 3677,   0, 2397,    0, 3421,    0, 2909,    0, 3933 ,                        
   0, 2269,    0, 3293,   0, 2781,    0, 3805,   0, 2525,    0, 3549,    0, 3037, 2013, 4061 ,                        
   0, 2109,    0, 3133,   0, 2621,    0, 3645,   0, 2365,    0, 3389,    0, 2877,    0, 3901 ,                        
   0, 2237,    0, 3261,   0, 2749,    0, 3773,   0, 2493,    0, 3517,    0, 3005,    0, 4029 ,                        
   0, 2173,    0, 3197,   0, 2685,    0, 3709,   0, 2429,    0, 3453,    0, 2941,    0, 3965 ,                        
   0, 2301,    0, 3325,   0, 2813,    0, 3837,   0, 2557,    0, 3581,    0, 3069,    0, 4093 ,                        
   0,    0,    0, 3075,   0, 2563,    0, 3587,   0, 2307,    0, 3331,    0, 2819,    0, 3843 ,                        
   0, 2179,    0, 3203,   0, 2691,    0, 3715,   0, 2435,    0, 3459,    0, 2947,    0, 3971 ,                        
   0,    0,    0, 3139,   0, 2627,    0, 3651,   0, 2371,    0, 3395,    0, 2883,    0, 3907 ,                        
   0, 2243,    0, 3267,   0, 2755,    0, 3779,   0, 2499,    0, 3523,    0, 3011,    0, 4035 ,                        
   0,    0,    0, 3107,   0, 2595,    0, 3619,   0, 2339,    0, 3363,    0, 2851,    0, 3875 ,                        
   0,    0,    0, 3235,   0, 2723,    0, 3747,   0, 2467,    0, 3491,    0, 2979,    0, 4003 ,                        
   0,    0,    0, 3171,   0, 2659,    0, 3683,   0, 2403,    0, 3427,    0, 2915,    0, 3939 ,                        
   0,    0,    0, 3299,   0, 2787,    0, 3811,   0, 2531,    0, 3555,    0, 3043,    0, 4067 ,                        
   0,    0,    0, 3091,   0, 2579,    0, 3603,   0,    0,    0, 3347,    0, 2835,    0, 3859 ,                        
   0,    0,    0, 3219,   0, 2707,    0, 3731,   0, 2451,    0, 3475,    0, 2963,    0, 3987 ,                        
   0,    0,    0, 3155,   0, 2643,    0, 3667,   0,    0,    0, 3411,    0, 2899,    0, 3923 ,                        
   0,    0,    0, 3283,   0, 2771,    0, 3795,   0, 2515,    0, 3539,    0, 3027,    0, 4051 ,                        
   0,    0,    0, 3123,   0, 2611,    0, 3635,   0,    0,    0, 3379,    0, 2867,    0, 3891 ,                        
   0,    0,    0, 3251,   0, 2739,    0, 3763,   0,    0,    0, 3507,    0, 2995,    0, 4019 ,                        
   0,    0,    0, 3187,   0, 2675,    0, 3699,   0,    0,    0, 3443,    0, 2931,    0, 3955 ,                        
   0,    0,    0, 3315,   0, 2803,    0, 3827,   0,    0,    0, 3571,    0, 3059,    0, 4083 ,                        
   0,    0,    0, 3083,   0,    0,    0, 3595,   0,    0,    0, 3339,    0, 2827,    0, 3851 ,                        
   0,    0,    0, 3211,   0, 2699,    0, 3723,   0,    0,    0, 3467,    0, 2955,    0, 3979 ,                        
   0,    0,    0, 3147,   0,    0,    0, 3659,   0,    0,    0, 3403,    0, 2891,    0, 3915 ,                        
   0,    0,    0, 3275,   0, 2763,    0, 3787,   0,    0,    0, 3531,    0, 3019,    0, 4043 ,                        
   0,    0,    0, 3115,   0,    0,    0, 3627,   0,    0,    0, 3371,    0, 2859,    0, 3883 ,                        
   0,    0,    0, 3243,   0,    0,    0, 3755,   0,    0,    0, 3499,    0, 2987,    0, 4011 ,                        
   0,    0,    0, 3179,   0,    0,    0, 3691,   0,    0,    0, 3435,    0, 2923,    0, 3947 ,                        
   0,    0,    0, 3307,   0,    0,    0, 3819,   0,    0,    0, 3563,    0, 3051,    0, 4075 ,                        
   0,    0,    0, 3099,   0,    0,    0, 3611,   0,    0,    0, 3355,    0,    0,    0, 3867 ,                        
   0,    0,    0, 3227,   0,    0,    0, 3739,   0,    0,    0, 3483,    0, 2971,    0, 3995 ,                        
   0,    0,    0, 3163,   0,    0,    0, 3675,   0,    0,    0, 3419,    0,    0,    0, 3931 ,                        
   0,    0,    0, 3291,   0,    0,    0, 3803,   0,    0,    0, 3547,    0, 3035,    0, 4059 ,                        
   0,    0,    0, 3131,   0,    0,    0, 3643,   0,    0,    0, 3387,    0,    0,    0, 3899 ,                        
   0,    0,    0, 3259,   0,    0,    0, 3771,   0,    0,    0, 3515,    0,    0,    0, 4027 ,                        
   0,    0,    0, 3195,   0,    0,    0, 3707,   0,    0,    0, 3451,    0,    0,    0, 3963 ,                        
   0,    0,    0, 3323,   0,    0,    0, 3835,   0,    0,    0, 3579,    0,    0,    0, 4091 ,                        
   0,    0,    0,    0,   0,    0,    0, 3591,   0,    0,    0, 3335,    0,    0,    0, 3847 ,                        
   0,    0,    0, 3207,   0,    0,    0, 3719,   0,    0,    0, 3463,    0,    0,    0, 3975 ,                        
   0,    0,    0,    0,   0,    0,    0, 3655,   0,    0,    0, 3399,    0,    0,    0, 3911 ,                        
   0,    0,    0, 3271,   0,    0,    0, 3783,   0,    0,    0, 3527,    0,    0,    0, 4039 ,                        
   0,    0,    0,    0,   0,    0,    0, 3623,   0,    0,    0, 3367,    0,    0,    0, 3879 ,                        
   0,    0,    0,    0,   0,    0,    0, 3751,   0,    0,    0, 3495,    0,    0,    0, 4007 ,                        
   0,    0,    0,    0,   0,    0,    0, 3687,   0,    0,    0, 3431,    0,    0,    0, 3943 ,                        
   0,    0,    0,    0,   0,    0,    0, 3815,   0,    0,    0, 3559,    0,    0,    0, 4071 ,                        
   0,    0,    0,    0,   0,    0,    0, 3607,   0,    0,    0,    0,    0,    0,    0, 3863 ,                        
   0,    0,    0,    0,   0,    0,    0, 3735,   0,    0,    0, 3479,    0,    0,    0, 3991 ,                        
   0,    0,    0,    0,   0,    0,    0, 3671,   0,    0,    0,    0,    0,    0,    0, 3927 ,                        
   0,    0,    0,    0,   0,    0,    0, 3799,   0,    0,    0, 3543,    0,    0,    0, 4055 ,                        
   0,    0,    0,    0,   0,    0,    0, 3639,   0,    0,    0,    0,    0,    0,    0, 3895 ,                        
   0,    0,    0,    0,   0,    0,    0, 3767,   0,    0,    0,    0,    0,    0,    0, 4023 ,                        
   0,    0,    0,    0,   0,    0,    0, 3703,   0,    0,    0,    0,    0,    0,    0, 3959 ,                        
   0,    0,    0,    0,   0,    0,    0, 3831,   0,    0,    0,    0,    0,    0,    0, 4087 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 3855 ,                        
   0,    0,    0,    0,   0,    0,    0, 3727,   0,    0,    0,    0,    0,    0,    0, 3983 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 3919 ,                        
   0,    0,    0,    0,   0,    0,    0, 3791,   0,    0,    0,    0,    0,    0,    0, 4047 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 3887 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 4015 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 3951 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 4079 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0,    0 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 3999 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0,    0 ,                        
   0,    0,    0,    0,   0,    0,    0,    0,   0,    0,    0,    0,    0,    0,    0, 4063 };                        
//{0.0, 1.0000000, 0.70710677, 0.38268346, 0.19509032, 0.098017141, 0.049067676,
//	   0.024541229,0.012271538, 0.0061358847,0.0030679568, 0.0015339802};
int sinsheet[12] ={0, 0x3f800000, 0x3f3504f3, 0x3ec3ef16, 0x3e47c5c2, 0x3dc8bd36, 0x3d48fb30, 0x3cc90ab0, 0x3c490e90, 0x3bc90f88, 0x3b490fc6, 0x3ac90fd6};



#define KERNEL(...) #__VA_ARGS__
/**
 * \var ILKernel 
 * \brief simple IL kernel that multiplies a value by a constant
 *
 * The value is read in based on the coordinates from vpos from a texture.
 * The texture is then multiplied by a constant value before being written
 * to the output texture.
 */

const CALchar * FFT_FULL_KERNEL=KERNEL(
il_ps_2_0
dcl_input_position_interp(linear_noperspective) vWinCoord0.xy__
dcl_cb cb0[1984]
dcl_literal l1, 0x00000400, 0, 0x2, 0x1000
flr r0.xy__, vWinCoord0.xy
ftou r0, r0
ftou r1, r1
umad r0.__z_, r0.x, l1.x, r0.y
mul r0.__z_, r0.z, l1.x
call 1
endmain
func1 //this function use r1
mov r1.x___, l3.x //init index
mov r1._y__, l3.zzzz  //index increamental
mov r1.__z_,l4.wwww //index upper bound
whileloop
    //r1 is for this loop, r1.x is index, r1.y is index inc, r1.z is bound, r1.w is boolean
    uge r1.___w, r1.x, r1.z   //
    break_logicalnz r1.w
    if_logicalnz cb0[r1.x].x
        //get index of target position, target is at r2.x->r2.y
		umod r2._y__, cb0[r1.x].x, l1.y //r2.x = cb[i] mod 4 uint
        ushr r2.x___, cb0[r1.x].x, l1.z //r2.y = cb[i]/4 uint
        //get index of current position, current is at r2.z->r2.w
		ishl r2.__z_, r1.x, l3.z        //r2.z = 2i uint
        iadd r2.__z_, r2.__z_, l3.z     //r2.z = 2i+1
        umod r2.___w, r2.z, l1.y        //r2.w = 2i+1 % 4 uint
        ushr r2.__z_, r2.__z_, l1.z     //r2.z = (2i+1)/4 uint
		//get index in the real matrix
		iadd r2.x___, r2.x, r0.z //r2.x is the real index of source
		iadd r2.__z_, r2.z, r0.z //r2.z is the real index of target
		ieq r1.___w, r2.w, l3.z  //reuse r1.w
        if_logicalnz r1.w //if(2i+1 mod 4 == 1)
        //2i+1 mod 4  == 1, r0->xy
			ieq r1.___w, r2.y, l3.z
            if_logicalnz r1.w
			//if(cb[i] mod 4 == 1)
                mov r3.xy__, g[r2.x].xy
                mov g[r2.x].xy__, g[r2.z].xy
                mov g[r2.z].xy__, r3.xy
			else
                mov r3.xy__, g[r2.x].xy
                mov g[r2.x].xy__, g[r2.z].zw
                mov g[r2.z].__zw, r3.xyxy
            endif
        else 
        //2i+1 mod 4  == 3, r0->zw
			ieq r1.___w, r2.y, l3.z
            if_logicalnz r1.w
			//if(cb[i] mod 4 == 1)
                mov r3.__zw, g[r2.x].zwzw
                mov g[r2.x].__zw, g[r2.z].xyxy
                mov g[r2.z].xy__, r3.zw
			else
                mov r3.__zw, g[r2.x].xyzw
                mov g[r2.x].__zw, g[r2.z].zwzw
                mov g[r2.z].__zw, r3.zwzw
            endif
        endif
	endif
	iadd r1.x___, r1.x, r1.y
endloop
ret
endfunc
end
);

const CALchar * FFT_KERNEL = KERNEL(
il_ps_2_0
dcl_input_position_interp(linear_noperspective) vWinCoord0.xy__
dcl_cb cb0[2048]
dcl_literal l1, 0x00000200, 0x00000004, 0x2, 0x800
dcl_literal l2, 6.28318530717959, 0.5, -2.0, 1.0
dcl_literal l3, 0x00000000, 0x00000003, 0x00000001, 992
dcl_literal l4, 0x00000000, 0x00000000, 0x00000000, 360
dcl_literal l5, 0, 1.0, -1.0, 1024.0  //flat and const for FFT and IFFT
flr r4.xy__, vWinCoord0.xyxy
ftou r4, r4
call 1
call 3
call 2
endmain
func 3
mov r1.x___, l3.x
whileloop
  uge r4.__z_, r1.x, l1.x
  break_logicalnz r4.z
  mul g[r1.x].xy__, g[r1.x].xy, cb0[r1.x].z
  mul g[r1.x].__zw, g[r1.x].zw, cb0[r1.x].w
  iadd r1.x___, r1.x, l3.z
endloop
ret
endfunc
func 1
mov r1.x___, l3.x
whileloop
    uge r4.__z_, r1.x, l3.w   //if(r4.z-> r1.x >= 992) r1.x = 0 to r1.x++
    break_logicalnz r4.z
    if_logicalnz cb0[r1.x].x
        umod r7.x___, cb0[r1.x].x, l1.y //r7.x = cb[i] mod 4 uint
        ushr r7._y__, cb0[r1.x].x, l1.z //r7.y = cb[i]/4 uint
        ishl r7.__z_, r1.x, l3.z        //r7.z = 2i uint
        iadd r7.__z_, r7.__z_, l3.z     //r7.z = 2i+1
        umod r7.___w, r7.z, l1.y        //r7.w = 2i+1 % 4 uint
        ushr r7.__z_, r7.__z_, l1.z     //r7.z = (2i+1)/4 uint
        //umad r0.x___, r4.y, l1.x, r7.z //r0.x  = index of 2i+1/4
        //umad r3.x___, r4.y, l1.x, r7.y //r3.x = index of cb[i]/4
		umad r0.x___, r4.x, l4.w, r4.y //x(0~359) y(0~255)
		umad r0.x___, r0.x, l1.x, r7.z
        umad r3.x___, r0.x, l1.x, r7.y
        ieq r6.x___, r7.w, l3.z
        if_logicalnz r6.x //if(2i+1 mod 4 == 1)
        //2i+1 mod 4  == 1, r0->xy
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y 
			//if(cb[i] mod 4 == 1)
                mov r5.xy__, g[r0.x].xyxy
                mov g[r0.x].xy__, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.xyxy
			else
                mov r5.xy__, g[r0.x].xy
                mov g[r0.x].xy__, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.xyxy
            endif
        else 
        //2i+1 mod 4  == 3, r0->zw
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y
			//if(cb[i] mod 4 == 1)
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.zwzw
			else
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.zwzw
            endif
        endif
    endif
    iadd r1.x___, r1.x, l3.z
endloop
//Swap done!!!. only r4.y is needed, r4 is unsigned int
mov r1.x, l1.z //r1.x = mmax = 2 uint.
mov r7.x, l3.x //r7.x = 0 unit is the position of sinsheet
whileloop
    uge r4.__z_, r1.x, l1.w //mmax>= 6, break
    break_logicalnz r4.z
    ishl r0.x___, r1.x,l3.z //r0.x = istep = mmax*2 uint
	
	mov r1.___w, cb0[r7.x].y//r1.w = wpi = sin(theta);
	iadd r7.x___, r7.x, l3.z //r7.x++
    mov r1._y__, cb0[r7.x] //r1.y = wtemp = sin(0.5*theta)
	mul r1.__z_, r1.y, r1.y
    mul r1.__z_, r1.z, l2.z //r1.z = wpr = -2.0f*wtemp*wtemp;

    mov r2.x___, l2.w //r2.x = wr = 1.0;
    mov r2._y__, l3.x //r2.y = wi = 0.0;
    mov r0._y__, l3.z //r0.y = m = 1 unsigned int 
    whileloop
        uge r0.__z_, r0.y, r1.x//m>= mmax, break
        break_logicalnz r0.z
        mov r0.___w, r0.y //r0.w = i = m unsigned int 
        umod r3._y__, r0.y, l1.y //m%4, all i%4 = m%4 for istep = 4n
        whileloop
            uge r0.__z_, r0.w, l1.w//if(i>=4096) break
            break_logicalnz r0.z
			iadd r3.x___, r0.w, r1.x //r3.x = j = i+mmax uint
 
			umad r8.x___, r4.x, l4.w, r4.y //x(0~359) y(0~255)
			
            ushr r2.___w, r0.___w, l1.z     //r2.w = i/4
            umad r2.___w, r8.x, l1.x, r2.w //r0.w = index of i/4

            ushr r3.x___, r3.x, l1.z       //j/4
            umad r3.x___, r8.x, l1.x, r3.x //r3.x = index of j/4

            ieq r3.__z_, r1.x, l1.z
            if_logicalnz r3.z //if(mmax == 2), i%4=1, j%4=3
                mul r6.x___, g[r3.x].z, r2.x
                mul r6._y__, g[r3.x].w, r2.y
                sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

                mul r6.x___, g[r3.x].w, r2.x
                mul r6._y__, g[r3.x].z, r2.y
                add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

                sub g[r3.x].__z_, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
                sub g[r3.x].___w, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
                add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
                add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
            else
                ieq r3.___w, r3.y, l3.z 
                if_logicalnz r3.w //if i%4 ==1, j%4=1 for mmax = 4n
                    mul r6.x___, g[r3.x].x, r2.x
                    mul r6._y__, g[r3.x].y, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].y, r2.x
					mul r6._y__, g[r3.x].x, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].x___, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x]._y__, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
					add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
                else // i%4 = j%4 =3
                    mul r6.x___, g[r3.x].z, r2.x
                    mul r6._y__, g[r3.x].w, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].w, r2.x
					mul r6._y__, g[r3.x].z, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].__z_, g[r2.w].z, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x].___w, g[r2.w].w, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].__z_, g[r2.w].z, r6.z //data[i] += tempr;
					add g[r2.w].___w, g[r2.w].w, r6.w	//data[i+1] += tempi;
                endif
            endif
 
            iadd r0.___w, r0.w,r0.x //i=i+istep
        endloop
        mov r1._y__, r2.x //wtemp = wr
        mul r6.x___, r1.y, r1.z //(wtemp = wr)*wpr
        mul r6._y__, r2.y, r1.w //wi*wpi
        sub r6.x___, r6.x, r6.y//(wtemp = wr)*wpr - wi*wpi
        add r2.x___, r6.x, r2.x //wr = (wtemp = wr)*wpr - wi*wpi + wr;

        mul r6.x___, r2.y, r1.z //wi*wpr
        mul r6._y__, r1.y, r1.w //wtemp*wpi
        add r6.x___, r6.x, r6.y//wi*wpr + wtemp*wpi
        add r2._y__, r6.x, r2.y //wi = wi*wpr + wtemp*wpi + wi;
        iadd r0._y__, r0.y,l1.z //m = m+2
    endloop
    mov r1.x___, r0.x
endloop
ret
endfunc
func 2
mov r1.x___, l3.x
whileloop
    uge r4.__z_, r1.x, l3.w   //if(r4.z-> r1.x >= 1984) r1.x = 0 to r1.x++
    break_logicalnz r4.z
    if_logicalnz cb0[r1.x].x
        umod r7.x___, cb0[r1.x].x, l1.y //r7.x = cb[i] mod 4 uint
        ushr r7._y__, cb0[r1.x].x, l1.z //r7.y = cb[i]/4 uint
        ishl r7.__z_, r1.x, l3.z        //r7.z = 2i uint
        iadd r7.__z_, r7.__z_, l3.z     //r7.z = 2i+1
        umod r7.___w, r7.z, l1.y        //r7.w = 2i+1 % 4 uint
        ushr r7.__z_, r7.__z_, l1.z     //r7.z = (2i+1)/4 uint
        umad r0.x___, r4.y, l1.x, r7.z //r0.x  = index of 2i+1/4
        umad r3.x___, r4.y, l1.x, r7.y //r3.x = index of cb[i]/4
        ieq r6.x___, r7.w, l3.z
        if_logicalnz r6.x //if(2i+1 mod 4 == 1)
        //2i+1 mod 4  == 1, r0->xy
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y 
			//if(cb[i] mod 4 == 1)
                mov r5.xy__, g[r0.x].xyxy
                mov g[r0.x].xy__, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.xyxy
			else
                mov r5.xy__, g[r0.x].xy
                mov g[r0.x].xy__, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.xyxy
            endif
        else 
        //2i+1 mod 4  == 3, r0->zw
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y
			//if(cb[i] mod 4 == 1)
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.zwzw
			else
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.zwzw
            endif
        endif
    endif
    iadd r1.x___, r1.x, l3.z
endloop
//Swap done!!!. only r4.y is needed, r4 is unsigned int
mov r1.x, l1.z //r1.x = mmax = 2 uint.
mov r7.x, l3.x //r7.x = 0 unit is the position of sinsheet
whileloop
    uge r4.__z_, r1.x, l1.w //mmax>= 6, break
    break_logicalnz r4.z
    ishl r0.x___, r1.x,l3.z //r0.x = istep = mmax*2 uint
	
	mov r1.___w, cb0[r7.x].y//r1.w = wpi = sin(theta);
	mul r1.___w, r1.w,l5.z
	iadd r7.x___, r7.x, l3.z //r7.x++
    mov r1._y__, cb0[r7.x] //r1.y = wtemp = sin(0.5*theta)
	mul r1.__z_, r1.y, r1.y
    mul r1.__z_, r1.z, l2.z //r1.z = wpr = -2.0f*wtemp*wtemp;

    mov r2.x___, l2.w //r2.x = wr = 1.0;
    mov r2._y__, l3.x //r2.y = wi = 0.0;
    mov r0._y__, l3.z //r0.y = m = 1 unsigned int 
    whileloop
        uge r0.__z_, r0.y, r1.x//m>= mmax, break
        break_logicalnz r0.z
        mov r0.___w, r0.y //r0.w = i = m unsigned int 
        umod r3._y__, r0.y, l1.y //m%4, all i%4 = m%4 for istep = 4n
        whileloop
            uge r0.__z_, r0.w, l1.w//if(i>=4096) break
            break_logicalnz r0.z
			iadd r3.x___, r0.w, r1.x //r3.x = j = i+mmax uint
 
            ushr r2.___w, r0.___w, l1.z     //r2.w = i/4
            umad r2.___w, r4.y, l1.x, r2.w //r0.w = index of i/4
            ushr r3.x___, r3.x, l1.z       //j/4
            umad r3.x___, r4.y, l1.x, r3.x //r3.x = index of j/4

            ieq r3.__z_, r1.x, l1.z
            if_logicalnz r3.z //if(mmax == 2), i%4=1, j%4=3
                mul r6.x___, g[r3.x].z, r2.x
                mul r6._y__, g[r3.x].w, r2.y
                sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

                mul r6.x___, g[r3.x].w, r2.x
                mul r6._y__, g[r3.x].z, r2.y
                add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

                sub g[r3.x].__z_, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
                sub g[r3.x].___w, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
                add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
                add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
            else
                ieq r3.___w, r3.y, l3.z 
                if_logicalnz r3.w //if i%4 ==1, j%4=1 for mmax = 4n
                    mul r6.x___, g[r3.x].x, r2.x
                    mul r6._y__, g[r3.x].y, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].y, r2.x
					mul r6._y__, g[r3.x].x, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].x___, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x]._y__, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
					add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
                else // i%4 = j%4 =3
                    mul r6.x___, g[r3.x].z, r2.x
                    mul r6._y__, g[r3.x].w, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].w, r2.x
					mul r6._y__, g[r3.x].z, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].__z_, g[r2.w].z, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x].___w, g[r2.w].w, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].__z_, g[r2.w].z, r6.z //data[i] += tempr;
					add g[r2.w].___w, g[r2.w].w, r6.w	//data[i+1] += tempi;
                endif
            endif
 
            iadd r0.___w, r0.w,r0.x //i=i+istep
        endloop
        mov r1._y__, r2.x //wtemp = wr
        mul r6.x___, r1.y, r1.z //(wtemp = wr)*wpr
        mul r6._y__, r2.y, r1.w //wi*wpi
        sub r6.x___, r6.x, r6.y//(wtemp = wr)*wpr - wi*wpi
        add r2.x___, r6.x, r2.x //wr = (wtemp = wr)*wpr - wi*wpi + wr;

        mul r6.x___, r2.y, r1.z //wi*wpr
        mul r6._y__, r1.y, r1.w //wtemp*wpi
        add r6.x___, r6.x, r6.y//wi*wpr + wtemp*wpi
        add r2._y__, r6.x, r2.y //wi = wi*wpr + wtemp*wpi + wi;
        iadd r0._y__, r0.y,l1.z //m = m+2
    endloop
    mov r1.x___, r0.x
endloop
mov r1.x___, l3.x //i=0
/*
whileloop
	uge r4.__z_, r1.x, l1.x //if(i>=1024) break
    break_logicalnz r4.z
	div g[r1.x], g[r1.x], l5.w
	iadd r1.x___, r1.x, l3.z
endloop
*/
ret
endfunc
end
);

const CALchar* ILKernel = KERNEL(
il_ps_2_0
dcl_input_position_interp(linear_noperspective) vWinCoord0.xy__
dcl_cb cb0[1984]
dcl_literal l1, 0x00000400, 0x00000004, 0x2, 0x1000
dcl_literal l2, 6.28318530717959, 0.5, -2.0, 1.0
dcl_literal l3, 0x00000000, 0x00000003, 0x00000001, 1984
dcl_literal l4, 0x6,4.0,0.0,1.0
dcl_literal l5, 0x3,0x4,0,1
dcl_literal l6, 0xc5000000, 0xc5000000,0,0
flr r4.xy__, vWinCoord0.xyyy
mov r4.x___, l3.x
ftou r4, r4
whileloop
    uge r4.__z_, r4.x, l3.w   //if(r4.z-> r4.x >= 1984) r4.x = 0 to r4.x++
    break_logicalnz r4.z
    if_logicalnz cb0[r4.x].x
        umod r7.x___, cb0[r4.x].x, l1.y //r7.x = cb[i] mod 4 uint
        ushr r7._y__, cb0[r4.x].x, l1.z //r7.y = cb[i]/4 uint
        ishl r7.__z_, r4.x, l3.z        //r7.z = 2i uint
        iadd r7.__z_, r7.__z_, l3.z     //r7.z = 2i+1
        umod r7.___w, r7.z, l1.y        //r7.w = 2i+1 % 4 uint
        ushr r7.__z_, r7.__z_, l1.z     //r7.z = (2i+1)/4 uint
        umad r0.x___, r4.y, l1.x, r7.z //r0.x  = index of 2i+1/4
        umad r3.x___, r4.y, l1.x, r7.y //r3.x = index of cb[i]/4
        ieq r6.x___, r7.w, l3.z
        if_logicalnz r6.x //if(2i+1 mod 4 == 1)
        //2i+1 mod 4  == 1, r0->xy
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y 
			//if(cb[i] mod 4 == 1)
                mov r5.xy__, g[r0.x].xyxy
                mov g[r0.x].xy__, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.xyxy
			else
                mov r5.xy__, g[r0.x].xy
                mov g[r0.x].xy__, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.xyxy
            endif
        else 
        //2i+1 mod 4  == 3, r0->zw
			ieq r6._y__, r7.x, l3.z
            if_logicalnz r6.y
			//if(cb[i] mod 4 == 1)
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].xyxy
                mov g[r3.x].xy__, r5.zwzw
			else
                mov r5.__zw, g[r0.x].zwzw
                mov g[r0.x].__zw, g[r3.x].zwzw
                mov g[r3.x].__zw, r5.zwzw
            endif
        endif
    endif
    iadd r4.x___, r4.x, l3.z
endloop
//Swap done!!!. only r4.y is needed, r4 is unsigned int
mov r4.x, l1.z //r4.x = mmax = 2 uint.
mov r7.x, l3.x //r7.x = 0 unit is the position of sinsheet
whileloop
    uge r4.__z_, r4.x, l1.w //mmax>= 6, break
    break_logicalnz r4.z
    ishl r0.x___, r4.x,l3.z //r0.x = istep = mmax*2 uint
	mov r1.___w, cb0[r7.x].y//r1.w = wpi = sin(theta);

	iadd r7.x___, r7.x, l3.z //r7.x++
    mov r1._y__, cb0[r7.x] //r1.y = wtemp = sin(0.5*theta)
	mul r1.__z_, r1.y, r1.y
    mul r1.__z_, r1.z, l2.z //r1.z = wpr = -2.0f*wtemp*wtemp;

    mov r2.x___, l2.w //r2.x = wr = 1.0;
    mov r2._y__, l3.x //r2.y = wi = 0.0;
    mov r0._y__, l3.z //r0.y = m = 1 unsigned int 
    whileloop
        uge r0.__z_, r0.y, r4.x//m>= mmax, break
        break_logicalnz r0.z
        mov r0.___w, r0.y //r0.w = i = m unsigned int 
        umod r3._y__, r0.y, l1.y //m%4, all i%4 = m%4 for istep = 4n
        whileloop
            uge r0.__z_, r0.w, l1.w//if(i>=4096) break
            break_logicalnz r0.z
			iadd r3.x___, r0.w, r4.x //r3.x = j = i+mmax uint
 
            ushr r2.___w, r0.___w, l1.z     //r2.w = i/4
            umad r2.___w, r4.y, l1.x, r2.w //r0.w = index of i/4
            ushr r3.x___, r3.x, l1.z       //j/4
            umad r3.x___, r4.y, l1.x, r3.x //r3.x = index of j/4

            ieq r3.__z_, r4.x, l1.z
            if_logicalnz r3.z //if(mmax == 2), i%4=1, j%4=3
                mul r6.x___, g[r3.x].z, r2.x
                mul r6._y__, g[r3.x].w, r2.y
                sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

                mul r6.x___, g[r3.x].w, r2.x
                mul r6._y__, g[r3.x].z, r2.y
                add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

                sub g[r3.x].__z_, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
                sub g[r3.x].___w, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
                add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
                add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
            else
                ieq r3.___w, r3.y, l3.z 
                if_logicalnz r3.w //if i%4 ==1, j%4=1 for mmax = 4n
                    mul r6.x___, g[r3.x].x, r2.x
                    mul r6._y__, g[r3.x].y, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].y, r2.x
					mul r6._y__, g[r3.x].x, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].x___, g[r2.w].x, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x]._y__, g[r2.w].y, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].x___, g[r2.w].x, r6.z //data[i] += tempr;
					add g[r2.w]._y__, g[r2.w].y, r6.w	//data[i+1] += tempi;
                else // i%4 = j%4 =3
                    mul r6.x___, g[r3.x].z, r2.x
                    mul r6._y__, g[r3.x].w, r2.y
					sub r6.__z_, r6.x, r6.y //r6.z = tempr = wr*data[j]-wi*data[j+1] float

					mul r6.x___, g[r3.x].w, r2.x
					mul r6._y__, g[r3.x].z, r2.y
					add r6.___w, r6.x, r6.y //r6.w = tempi = wr*data[j+1]+wi*data[j] float

					sub g[r3.x].__z_, g[r2.w].z, r6.z	//data[j] = data[i]-tempr;
					sub g[r3.x].___w, g[r2.w].w, r6.w //data[j+1] = data[i+1]-tempi;
					add g[r2.w].__z_, g[r2.w].z, r6.z //data[i] += tempr;
					add g[r2.w].___w, g[r2.w].w, r6.w	//data[i+1] += tempi;
                endif
            endif
 
            iadd r0.___w, r0.w,r0.x //i=i+istep
        endloop
        mov r1._y__, r2.x //wtemp = wr
        mul r6.x___, r1.y, r1.z //(wtemp = wr)*wpr
        mul r6._y__, r2.y, r1.w //wi*wpi
        sub r6.x___, r6.x, r6.y//(wtemp = wr)*wpr - wi*wpi
        add r2.x___, r6.x, r2.x //wr = (wtemp = wr)*wpr - wi*wpi + wr;

        mul r6.x___, r2.y, r1.z //wi*wpr
        mul r6._y__, r1.y, r1.w //wtemp*wpi
        add r6.x___, r6.x, r6.y//wi*wpr + wtemp*wpi
        add r2._y__, r6.x, r2.y //wi = wi*wpr + wtemp*wpi + wi;
        iadd r0._y__, r0.y,l1.z //m = m+2
    endloop
    mov r4.x___, r0.x
endloop
end
);

#endif


